﻿@using SolidCP.WebDavPortal.Resources
@using SolidCP.WebDavPortal.UI.Routes
@model SolidCP.WebDavPortal.Models.Account.PasswordResetFinalStepModel
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container row">
    @using (Html.BeginRouteForm(AccountRouteNames.PasswordResetFinalStep, FormMethod.Post, new { @class = "form-horizontal user-password-reset-final-step bs-val-styles col-lg-9 col-lg-offset-3", id = "user-password-reset" }))
    {
        @Html.HiddenFor(x=>x.Login)
        
        <div class="form-group">
            <h3>@UI.PasswordReset</h3>
        </div>
        
        <div class="form-group">
            <span>
                @string.Format(UI.YouRChangingPswForFormat, Model.Login)
            </span>
        </div>

        @Html.EditorFor(x => x.PasswordEditor)

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default">@UI.ChangePassword</button>
            </div>
        </div>
    }
</div>

@if (Model.PasswordEditor.Settings != null)
{
    <div class="form-group hidden" id="password-hint-popup">
        <ul>

            <li>
                @string.Format(Messages.PasswordMinLengthFormat, Model.PasswordEditor.Settings.MinimumLength)
            </li>
            <li>
                @string.Format(Messages.PasswordMaxLengthFormat, Model.PasswordEditor.Settings.MaximumLength)
            </li>

            @if (Model.PasswordEditor.Settings.PasswordComplexityEnabled)
            {
                if (Model.PasswordEditor.Settings.UppercaseLettersCount > 0)
                {
                    <li>
                        @string.Format(Messages.PasswordUppercaseCountFormat, Model.PasswordEditor.Settings.UppercaseLettersCount)
                    </li>
                }
                if (Model.PasswordEditor.Settings.NumbersCount > 0)
                {
                    <li>
                        @string.Format(Messages.PasswordNumbersCountFormat, Model.PasswordEditor.Settings.NumbersCount)
                    </li>
                }
                if (Model.PasswordEditor.Settings.SymbolsCount > 0)
                {
                    <li>
                        @string.Format(Messages.PasswordSymbolsCountFormat, Model.PasswordEditor.Settings.SymbolsCount)
                    </li>
                }
            }
        </ul>
    </div>
}

@section scripts{
    <script>
        $(function() {
            if ($(document).width() < 800) {
                $('.password-input').data('placement', "bottom");
            }

            $(".password-input").popover({
                    html: true,
                    title: '@UI.PasswordFollowingRequirements',
                    content: function() {
                        return $('#password-hint-popup').html();
                    }
                })
                .blur(function() {
                    $(this).popover('hide');
                });
        });
    </script>
}




